package tech.novastar.http;

import tech.novastar.domain.Store;
import tech.novastar.service.StoreService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/MainServlet")
public class MainServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StoreService storeService = new StoreService();
        List<Store> stores = storeService.fetchAllStore();
        request.setAttribute("stores", stores);

        request.getRequestDispatcher("/pages/index.jsp").forward(request, response);
    }
}

